package com.example.hehao.exam;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.Timer;
import java.util.TimerTask;

public class HuanYingActivity extends AppCompatActivity {

    private TextView tv_name;
    private ImageView iv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_huan_ying);

        tv_name = (TextView) findViewById(R.id.tv_name);
        iv = (ImageView) findViewById(R.id.iv);

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                HuanYingActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        tv_name.setVisibility(View.VISIBLE);
                        iv.setVisibility(View.VISIBLE);
                    }
                });
            }
        }).start();


        SharedPreferences sp = getSharedPreferences("sp",MODE_APPEND);
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean("first",true);
        editor.commit();


//        TimerTask task1 = new TimerTask() {
//            @Override
//            public void run() {
//                startActivity(new Intent(HuanYingActivity.this,ZhuActivity.class));
//                HuanYingActivity.this.finish();
//            }
//        };
//        Timer timer = new Timer();
//        timer.schedule(task1,4000);

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(4000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                startActivity(new Intent(HuanYingActivity.this,ZhuActivity.class));
                HuanYingActivity.this.finish();
            }
        }).start();
    }
}
